<template>
	<view class="detail-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="通知公告详情"></uni-navbar></view>

		<view class="detail-info" v-show="sysMsg.id">
			<view class="info-title">
				<view class="title-top">{{ sysMsg.msgTitle }}</view>
				<view class="title-btm">
					<text class="btm-time">{{ sysMsg.createTime | parseTime('{y}-{m}-{d}') }}</text>
				</view>
			</view>
			<view class="info-detail">
				<view class="overflow"><uni-parse :content="sysMsg.msgContent"></uni-parse></view>
			</view>
		</view>

		<view class="uploader-add" @click="onTts">
			<image v-if="!play" src="/static/img/icon_76.png" mode="widthFix"></image>
			<image src="/static/img/icon_77.gif" v-else mode="widthFix"></image>
		</view>

		<view class="form-box form-box-show">
			<u-form ref="uForm">
				<u-form-item class="form-item" label="发送人" labelAlign="left" label-width="190">{{ sysMsg.sendUserName }}</u-form-item>
				<u-form-item class="form-item" label="消息类别" labelAlign="left" label-width="190">{{ typeMap[sysMsg.bizType] }}</u-form-item>
				<u-form-item class="form-item" label="发送时间" labelAlign="left" label-width="190">{{ sysMsg.sendDate | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</u-form-item>
				<u-form-item class="form-item" label="阅读时间" labelAlign="left" label-width="190">{{ sysMsg.readDate | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</u-form-item>
			</u-form>
		</view>
	</view>
</template>

<script>
import uniParse from '@/components/uni-parse/parse.vue';
import { mapState } from 'vuex';
export default {
	components: {
		uniParse
	},
	data() {
		return {
			typeList: {},
			typeMap: {
				'1': '建议办理',
				'2': '民情直通',
				'3': '会议活动',
				'4': '履职管理',
				'5': '协商议事',
				'6': '互动交流'
			},
			id: '',
			sysMsg: '',
			play: false
		};
	},
	onLoad(option) {
		this.loadLogin();
		this.id = option.id;
		this.loadData();
	},
	onHide() {
		this.$ttsOff();
	},
	onUnload() {
		this.$ttsOff();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.sysUser) {
			} else {
				this.$logout();
			}
		},
		loadData() {
			this.$request('/system/sysMsgPush/query?id=' + this.id).then(res => {
				this.sysMsg = res.data;
			});
		},
		onTts() {
			let text = this.sysMsg.msgTitle;
			text += ',' + this.$parseTime(this.sysMsg.createTime, '{y}-{m}-{d}');
			text += ',' + this.$htmlRegx(this.sysMsg.msgContent);
			this.$tts(text, this, 500);
		}
	}
};
</script>

<style lang="scss">
.detail-view {
	background-color: #fff;
}

.form-box {
	border-top: 10rpx solid #f5f7fa;

	.form-item {
		display: block;
		padding: 0 30rpx;
	}
}

.fiexd-btm {
	position: static;
	border-top: 10rpx solid #f5f7fa;
	padding: 30rpx;
}
</style>
